# Flask示例：app.py
from flask import Flask, request, jsonify

import schedule
import db1
import db3

app = Flask(__name__)


@app.route('/generate', methods=['post'])
def generate_schedule():
    data = request.get_json()
    deptId = data['deptId']
    year = data['year']
    term = data['term']
    # 根据不同的院系id选择不同的操作
    if deptId == '001':
        # ... 选择数据操作db1 ...
        db = db1
    elif deptId == '999':
        # ... 选择数据操作db3 ...
        db = db3
    schedule.schedule(db, deptId, year, term)
    # 状态返回
    return "ok"


# 程序入口
if __name__ == '__main__':
    app.run(port=9090)
